package com.parking.mgr.useraccount.facede;

import com.parking.mgr.useraccount.model.entity.BasicRoleAssignEntity;
import com.parking.mgr.useraccount.model.entity.BasicRoleEntity;
import com.parking.mgr.useraccount.model.entity.BasicRoleUserEntity;
import com.parking.mgr.useraccount.service.BasicRoleAssignService;
import com.parking.mgr.useraccount.service.BasicRoleMenuService;
import com.parking.mgr.useraccount.service.BasicRoleService;
import com.parking.mgr.useraccount.service.BasicRoleUserService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName RoleServiceFacede
 * @Description 角色service 外观模式
 * @Auther: zhijianpu
 * @Date: 2023/6/12
 */
@Component
public class BasicRoleServiceFacede {

    @Resource
    private BasicRoleUserService basicRoleUserService;

    @Resource
    private BasicRoleAssignService basicRoleAssignService;

    @Resource
    private BasicRoleMenuService basicRoleMenuService;

    @Resource
    private BasicRoleService basicRoleService;

    /**
     * 根据用户账户获取用户角色列表实体
     *
     * @param passportId
     * @return
     */
    public List<BasicRoleUserEntity> getRoleUserEntityList(String passportId) {
        return basicRoleUserService.getRoleUserEntityList(passportId);
    }

    /**
     * 根据用户ID删除用户角色
     *
     * @param ids
     */
    public void deleteBatchUserRolesById(List<String> ids) {
        basicRoleUserService.deleteBatchUserRolesById(ids);
    }

    /**
     *  保存角色信息
     *
     * @param basicRoleUserEntity
     */
    public void save(BasicRoleUserEntity basicRoleUserEntity) {
        basicRoleUserService.save(basicRoleUserEntity);
    }

    /**
     * 根据用户账户获取用户角色列表
     *
     * @param passportId
     * @return
     */
    public List<String> getRoleUserList(String passportId) {
        return basicRoleUserService.getRoleUserList(passportId);
    }

    /**
     * 分配用户角色
     *
     * @param basicRoleAssignEntity 实体对象
     */
    public void save(BasicRoleAssignEntity basicRoleAssignEntity) {
        basicRoleAssignService.save(basicRoleAssignEntity);
    }

    /**
     * 获取用户角色列表获取角色功能菜单
     *
     * @param userRoleIds
     * @return
     */
    public List<String> getRoleUserMenuList(List<String> userRoleIds) {
        return basicRoleMenuService.getRoleUserMenuList(userRoleIds);
    }

    /**
     * 根据用户角色获取菜单列表
     *
     * @param roleId
     * @return
     */
    public List<String> getRoleMenuListByRoleId(String roleId) {
        return basicRoleMenuService.getRoleMenuListByRoleId(roleId);
    }

    public String getRoleIdByName(String roleName) {
        return basicRoleService.getRoleIdByName(roleName);
    }

    public String getOneByPassportId(String passportId) {
        return basicRoleUserService.getOneByPassportId(passportId);
    }

    public BasicRoleEntity getBasicRoleById(String id) {
        return basicRoleService.getBasicRoleById(id);
    }
}
